package org.lzy.shop.adapter

import android.content.Context
import android.view.ViewGroup
import android.widget.ImageView
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import org.lzy.shop.R
import org.lzy.shop.response.ListSearch
import org.lzy.shop.util.setUrl

class SearchGoodAdapter: BaseQuickAdapter<ListSearch, QuickViewHolder>() {
    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_search_good, parent)
    }

    override fun onBindViewHolder(
        holder: QuickViewHolder,
        position: Int,
        item: ListSearch?
    ) {
        item?.let {
            setUrl(item.mainPic,holder.getView<ImageView>(R.id.item_recommand_pic))
            holder.setText(R.id.item_recommand_title, item.title)
            holder.setText(R.id.item_recommand_subtitle, item.subTitle)
            holder.setText(R.id.item_recommand_price, "￥" + item.price)
            holder.setText(R.id.item_recommand_sell, "已售 " + item.sold)

        }
    }
}